﻿using System.Windows.Forms;

namespace Domotica.Gazing
{
    internal partial class SelectCameraForm : Form
    {
        public SelectCameraForm()
        {
            InitializeComponent();

            CameraList list = Camera.GetCameraList();
            cbxCamera.Items.AddRange(list.ToArray());
        }

        public void SetValue(int number, string name)
        {
            foreach (object c in cbxCamera.Items)
            {
                var camera = c as Camera;
                if (camera != null)
                {
                    if (camera.Number == number)
                    {
                        cbxCamera.SelectedItem = c;
                        return;
                    }
                }
            }
        }

        public void GetValue(ref int number, ref string name)
        {
            var camera = cbxCamera.SelectedItem as Camera;
            if (camera != null)
            {
                number = camera.Number;
                name = camera.Name;
            }
        }
    }
}